<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Kinetis Bootloader: Synchronization</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="nxp_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Kinetis Bootloader
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
   <div id="projectbrief">Common bootloader for Kinetis devices</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Introduction</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__rtos__irq__sync.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a>  </div>
  <div class="headertitle">
<div class="title">Synchronization<div class="ingroups"><a class="el" href="group__utilities.html">Utilities</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Synchronization resource.  
<a href="#details">More...</a></p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Collaboration diagram for Synchronization:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<center><table><tr><td><div class="center"><iframe scrolling="no" frameborder="0" src="group__rtos__irq__sync.svg" width="239" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</td></tr></table></center>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structsemaphore__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a></td></tr>
<tr class="separator:structsemaphore__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gaf19667353d40403b33dfac84ba8a3678"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaf19667353d40403b33dfac84ba8a3678"></a>
typedef volatile int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#gaf19667353d40403b33dfac84ba8a3678">sync_object_t</a></td></tr>
<tr class="memdesc:gaf19667353d40403b33dfac84ba8a3678"><td class="mdescLeft">&#160;</td><td class="mdescRight">Type for an interrupt synchronization object. <br /></td></tr>
<tr class="separator:gaf19667353d40403b33dfac84ba8a3678"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacf427a79d36893fa7874beee8271b9fc"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gacf427a79d36893fa7874beee8271b9fc"></a>
typedef volatile uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#gacf427a79d36893fa7874beee8271b9fc">lock_object_t</a></td></tr>
<tr class="memdesc:gacf427a79d36893fa7874beee8271b9fc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Type for an interrupt lock object. <br /></td></tr>
<tr class="separator:gacf427a79d36893fa7874beee8271b9fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gac620802974e82799bde8d7eeadecaea2"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a> { <br />
&#160;&#160;<a class="el" href="group__rtos__irq__sync.html#ggac620802974e82799bde8d7eeadecaea2aa4598af8363b288290d945d9853c4b32">kStatus_OSA_Success</a> = 0U, 
<br />
&#160;&#160;<a class="el" href="group__rtos__irq__sync.html#ggac620802974e82799bde8d7eeadecaea2afe784ce9a332a9b671d6b372840c60a1">kStatus_OSA_Error</a> = 1U, 
<br />
&#160;&#160;<a class="el" href="group__rtos__irq__sync.html#ggac620802974e82799bde8d7eeadecaea2a8a3efc503d4b3a9f785d00b6f5a72b53">kStatus_OSA_Timeout</a> = 2U, 
<br />
&#160;&#160;<a class="el" href="group__rtos__irq__sync.html#ggac620802974e82799bde8d7eeadecaea2a5ff8ef02cb571d5d5f92a7e816719a3d">kStatus_OSA_Idle</a> = 3U
<br />
 }</td></tr>
<tr class="separator:gac620802974e82799bde8d7eeadecaea2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga766649329a04f74317020a111afc12a3"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#ga766649329a04f74317020a111afc12a3">sync_timeouts</a> { <a class="el" href="group__rtos__irq__sync.html#gga766649329a04f74317020a111afc12a3acc89da1f516db1180e9b4355a378953b">kSyncWaitForever</a> = 0xffffffffU
 }</td></tr>
<tr class="separator:ga766649329a04f74317020a111afc12a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Counting Semaphore</h2></td></tr>
<tr class="memitem:ga38cbf578e5fe68f6b49d54acf5019ec6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#ga38cbf578e5fe68f6b49d54acf5019ec6">OSA_SemaCreate</a> (<a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *pSem, uint8_t initValue)</td></tr>
<tr class="memdesc:ga38cbf578e5fe68f6b49d54acf5019ec6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a semaphore with a given value.  <a href="#ga38cbf578e5fe68f6b49d54acf5019ec6">More...</a><br /></td></tr>
<tr class="separator:ga38cbf578e5fe68f6b49d54acf5019ec6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga653fc3e87d91a841348be7b0a0166422"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#ga653fc3e87d91a841348be7b0a0166422">OSA_SemaWait</a> (<a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *pSem, uint32_t timeout)</td></tr>
<tr class="memdesc:ga653fc3e87d91a841348be7b0a0166422"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pending a semaphore with timeout.  <a href="#ga653fc3e87d91a841348be7b0a0166422">More...</a><br /></td></tr>
<tr class="separator:ga653fc3e87d91a841348be7b0a0166422"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa5034a9787f489d989f22a06e509a192"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#gaa5034a9787f489d989f22a06e509a192">OSA_SemaPost</a> (<a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *pSem)</td></tr>
<tr class="memdesc:gaa5034a9787f489d989f22a06e509a192"><td class="mdescLeft">&#160;</td><td class="mdescRight">Signals for someone waiting on the semaphore to wake up.  <a href="#gaa5034a9787f489d989f22a06e509a192">More...</a><br /></td></tr>
<tr class="separator:gaa5034a9787f489d989f22a06e509a192"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3883e9e4302574d34a937c6d6eef4a35"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#ga3883e9e4302574d34a937c6d6eef4a35">OSA_SemaDestroy</a> (<a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *pSem)</td></tr>
<tr class="memdesc:ga3883e9e4302574d34a937c6d6eef4a35"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys a previously created semaphore.  <a href="#ga3883e9e4302574d34a937c6d6eef4a35">More...</a><br /></td></tr>
<tr class="separator:ga3883e9e4302574d34a937c6d6eef4a35"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga80ec77b248ae8f3d564727e0cb78eaee"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__rtos__irq__sync.html#ga80ec77b248ae8f3d564727e0cb78eaee">OSA_TimeDelay</a> (uint32_t delay)</td></tr>
<tr class="memdesc:ga80ec77b248ae8f3d564727e0cb78eaee"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delays execution for a number of milliseconds.  <a href="#ga80ec77b248ae8f3d564727e0cb78eaee">More...</a><br /></td></tr>
<tr class="separator:ga80ec77b248ae8f3d564727e0cb78eaee"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Usage Information</h2>
<p>Synchronization resource. </p>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structsemaphore__t" id="structsemaphore__t"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct semaphore_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<div class="textblock"></div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aa71878320984c51245a4310f6ff44236"></a>volatile bool</td>
<td class="fieldname">
isWaiting</td>
<td class="fielddoc">
<p>Is any task waiting for a timeout on this object </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a1d2f89fdf8829f51ee26417a25143535"></a>volatile uint8_t</td>
<td class="fieldname">
semCount</td>
<td class="fielddoc">
<p>The count value of the object </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a83aa7dd89e30afbc56dcc3dbe043a044"></a>uint64_t</td>
<td class="fieldname">
tickStart</td>
<td class="fielddoc">
<p>The ticks to start timeout </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ab5627d8d8b095c198e2523c44ca380ac"></a>uint32_t</td>
<td class="fieldname">
timeout</td>
<td class="fielddoc">
<p>Timeout to wait in milliseconds </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a class="anchor" id="gac620802974e82799bde8d7eeadecaea2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a class="anchor" id="ggac620802974e82799bde8d7eeadecaea2aa4598af8363b288290d945d9853c4b32"></a>kStatus_OSA_Success&#160;</td><td class="fielddoc">
<p>Success </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="ggac620802974e82799bde8d7eeadecaea2afe784ce9a332a9b671d6b372840c60a1"></a>kStatus_OSA_Error&#160;</td><td class="fielddoc">
<p>Failed </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="ggac620802974e82799bde8d7eeadecaea2a8a3efc503d4b3a9f785d00b6f5a72b53"></a>kStatus_OSA_Timeout&#160;</td><td class="fielddoc">
<p>Timeout occurs while waiting </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="ggac620802974e82799bde8d7eeadecaea2a5ff8ef02cb571d5d5f92a7e816719a3d"></a>kStatus_OSA_Idle&#160;</td><td class="fielddoc">
<p>Used for bare metal only, the wait object is not ready and timeout still not occur </p>
</td></tr>
</table>

</div>
</div>
<a class="anchor" id="ga766649329a04f74317020a111afc12a3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__rtos__irq__sync.html#ga766649329a04f74317020a111afc12a3">sync_timeouts</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a class="anchor" id="gga766649329a04f74317020a111afc12a3acc89da1f516db1180e9b4355a378953b"></a>kSyncWaitForever&#160;</td><td class="fielddoc">
<p>Constant to pass for the sync_wait() timeout in order to wait indefinitely. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga38cbf578e5fe68f6b49d54acf5019ec6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a> OSA_SemaCreate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>pSem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>initValue</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Creates a semaphore with a given value. </p>
<p>This function creates a semaphore and sets the value to the parameter initValue.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pSem</td><td>Pointer to the semaphore. </td></tr>
    <tr><td class="paramname">initValue</td><td>Initial value the semaphore will be set to.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">kStatus_OSA_Success</td><td>The semaphore is created successfully. </td></tr>
    <tr><td class="paramname">kStatus_OSA_Error</td><td>The semaphore can not be created.</td></tr>
  </table>
  </dd>
</dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;semaphore_t mySem;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;OSA_SemaCreate(&amp;mySem, 0);</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga3883e9e4302574d34a937c6d6eef4a35"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a> OSA_SemaDestroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>pSem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Destroys a previously created semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pSem</td><td>Pointer to the semaphore to destroy.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">kStatus_OSA_Success</td><td>The semaphore is successfully destroyed. </td></tr>
    <tr><td class="paramname">kStatus_OSA_Error</td><td>The semaphore can not be destroyed.</td></tr>
  </table>
  </dd>
</dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;osa_status_t status;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;status = OSA_SemaDestroy(&amp;mySem);</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;switch(status)</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;{</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;    //...</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;}</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gaa5034a9787f489d989f22a06e509a192"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a> OSA_SemaPost </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>pSem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Signals for someone waiting on the semaphore to wake up. </p>
<p>Wakes up one task that is waiting on the semaphore. If no task is waiting, increases the semaphore's counting value.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pSem</td><td>Pointer to the semaphore to signal.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">kStatus_OSA_Success</td><td>The semaphore is successfully signaled. </td></tr>
    <tr><td class="paramname">kStatus_OSA_Error</td><td>The object can not be signaled or invalid parameter.</td></tr>
  </table>
  </dd>
</dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;osa_status_t status;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;status = OSA_SemaPost(&amp;mySem);</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;switch(status)</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;{</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;    //...</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;}</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga653fc3e87d91a841348be7b0a0166422"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__rtos__irq__sync.html#gac620802974e82799bde8d7eeadecaea2">osa_status_t</a> OSA_SemaWait </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__rtos__irq__sync.html#structsemaphore__t">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>pSem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Pending a semaphore with timeout. </p>
<p>This function checks the semaphore's counting value. If it is positive, decreases it and returns kStatus_OSA_Success. Otherwise, a timeout is used to wait.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pSem</td><td>Pointer to the semaphore. </td></tr>
    <tr><td class="paramname">timeout</td><td>The maximum number of milliseconds to wait if semaphore is not positive. Pass OSA_WAIT_FOREVER to wait indefinitely, pass 0 will return kStatus_OSA_Timeout immediately.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">kStatus_OSA_Success</td><td>The semaphore is received. </td></tr>
    <tr><td class="paramname">kStatus_OSA_Timeout</td><td>The semaphore is not received within the specified 'timeout'. </td></tr>
    <tr><td class="paramname">kStatus_OSA_Error</td><td>An incorrect parameter was passed. </td></tr>
    <tr><td class="paramname">kStatus_OSA_Idle</td><td>The semaphore is not available and 'timeout' is not exhausted, This is only for bare metal.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>With bare metal, a semaphore can not be waited by more than one task at the same time.</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;osa_status_t status;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;status = OSA_SemaWait(&amp;mySem, 100);</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;switch(status)</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;{</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;    //...</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;}</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga80ec77b248ae8f3d564727e0cb78eaee"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void OSA_TimeDelay </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>delay</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delays execution for a number of milliseconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">delay</td><td>The time in milliseconds to wait. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Mar 7 2016 16:48:23 for Kinetis Bootloader by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
